#!/bin/sh
echo ""
echo "Configuring DHCP Server"
echo ""

IFCONFIG=`which ifconfig 2>/dev/null||echo /sbin/ifconfig`
IPADDR=`$IFCONFIG eth0|gawk '/inet addr/{print $2}'|gawk -F: '{print $2}'`

cat > /etc/dhcpd.conf <<EOF
ddns-update-style interim;
ignore client-updates;

subnet 192.168.0.0 netmask 255.255.255.0 {

  option routers                  192.168.0.3;
  option subnet-mask              255.255.255.0;
  option nis-domain               "voiper.local";
  option domain-name              "voiper.local";
  option domain-name-servers      192.168.0.10;
  option time-offset              -18000; # Eastern Standard Time
  option ntp-servers              $IPADDR;
  option tftp-server-name         "$IPADDR";

  range dynamic-bootp 192.168.0.100 192.168.0.150;
  default-lease-time 43200;
  max-lease-time 86400;
}
EOF

chkconfig --level 2345 dhcpd on

echo "Created /etc/dhcpd.conf and set dhcpd to autostart on reboot."
echo "you can edit /etc/dhcpd.cond and add you own options"
echo ""
